#include <iostream>
#include <thread>
#include <string>
#include <unistd.h>
#include <pthread.h>

__thread int g_val = 10; //线程的局部存储，加编译选项__thread，各线程持有一份

int main1()
{
    std::thread t([](){
        std::cout << "new thread" << std::endl;
    });

    t.join();

    return 0;
}

int main()
{
    pthread_t tid;
    pthread_create(&tid, nullptr, [](void* args) -> void* {
        std::cout << g_val << std::endl;
    }, (void*)"thread1");

    return 0;
}